﻿CREATE OR REPLACE FUNCTION trgfninsertbudget_detail()
  RETURNS trigger AS
	$BODY$ 
		Begin                    
			Insert INTO kdvn_budget_data (budget_id,project_id,budget_amount,create_date) (Select id as budget_id,new.id as project_id,0 as budget_amount,now() as create_date  from account_budget_post where set_default=True);
			Return NULL;                
		end;
	$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
ALTER FUNCTION trgfninsertbudget_lines() OWNER TO openerp;


CREATE TRIGGER trginsertbudget_data
  AFTER INSERT
  ON kdvn_project
  FOR EACH ROW
  EXECUTE PROCEDURE trgfninsertbudget_detail();
